<?php

namespace Support;

class UserManager {
    protected $user_list = [];

    public function login($socket) {
        $user = [
            'handshake' => 0,
            'name' => DEFAULT_USER_NAME,
            'socket' => $socket,
        ];

        $this->user_list[] = $user;
    }

    public function setUserName(&$user, $user_name) {
        $user['name'] = $user_name;
    }

    public function handshake(&$user) {
        $user['handshake'] = 1;
    }

    public function logout(&$user) {
    	unset($user);
    }

    public function &getUserInfo($socket) {
        foreach ($this->user_list as &$user) {
            if ($user['socket'] == $socket) {
                return $user;
            }
        }
    }

    public function getUserList() {
        return $this->user_list;
    }
}
